package com.zlx.exceptions;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @Author 周罗校
 * @Description 全局异常处理
 * @ClassName GlobalException
 * @date 2020.10.14 17:10:45
 * 该版权归周罗校所有，最终解释权以官方为准
 */

@ControllerAdvice
public class GlobalException {

    @ExceptionHandler(ArithmeticException.class)
    public String arithmeticException(ArithmeticException e, Model model){
        System.out.println(e);
        model.addAttribute("error",e);
        return "exception";
    }

    @ExceptionHandler(Exception.class)
    public String exception(Model model, Exception e){
        System.out.println(e);
        model.addAttribute("error","error");
        return "exception";
    }
}
